//
// Created by dddgzc on 2025/1/26.
//

#include "../include/Platform.h"

Platform::Platform(SDL_Texture *image, int x, int y): collisionShape() {
    this->image = image;
    SDL_QueryTexture(image, nullptr, nullptr, &width, &height);
    this->renderPosition = {x, y};
}

Platform::~Platform() {
    if (this->image != nullptr)
        SDL_DestroyTexture(this->image);
}

void Platform::onDraw(const Camera &camera) {
    draw(camera, image, renderPosition.x, renderPosition.y);
    if (IS_DEBUG_MODE) {
        // 绘制一条直线
        drawRedLine(camera, collisionShape.y, collisionShape.left, collisionShape.right);
    }
}

void Platform::setCollisionShape(int y, int left, int right) {
    this->collisionShape = {y, left, right};
}
